package com.somnus.androidkotlindemo.activity

import android.app.Dialog
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import com.somnus.androidkotlindemo.R
import com.somnus.androidkotlindemo.bean.KotlinBean
import com.somnus.androidkotlindemo.databinding.DataBingListActivity
import com.somnus.androidkotlindemo.kt.toast
import kotlinx.android.synthetic.main.activity_kotlin_ui.*

class KotlinUIActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_kotlin_ui)


        button.setOnClickListener {
            val dialog = Dialog(this, R.style.Base_Theme_AppCompat_Light_Dialog)
            val view: View = LayoutInflater.from(this@KotlinUIActivity).inflate(R.layout.layout_dialog, null)
            dialog.setTitle("title")
            dialog.setContentView(view)
            dialog.show()
        }
        var i: Int = 0
        button1.setOnClickListener {

            edit_taost.setText("Hello,Kotlin")
            i++
            toast(edit_taost.text.toString() + "$i")
        }

        /**
         * activity之间传值
         */
        var mKotBean = KotlinBean("张三", 1)
        Log.d("Bean", mKotBean.toString())
        button2.setOnClickListener {
            KotlinBeanActivity.startActivitySencond(this@KotlinUIActivity, mKotBean)
        }

        /**
         * recyclerView 演示
         */
        button3.setOnClickListener { startActivity(intent.setClass(this@KotlinUIActivity, RecyclerViewActivity::class.java)) }

        /**
         * 加入BaseRecyclerViewAdapter
         */
        button4.setOnClickListener { startActivity(intent.setClass(this@KotlinUIActivity, BaseRecyclerAdapterActivity::class.java)) }

        /**
         * 重叠布局
         */
        button5.setOnClickListener({
            ConstraintLayoutActivity.startConstraintLayoutActivity(this@KotlinUIActivity)

        })
        button6.setOnClickListener {
            DrawerActivity.startDrawarLayoutActivity(this@KotlinUIActivity)
        }
        button7.setOnClickListener { DiffUtilsActivity.startDiffUtilsActivity(this@KotlinUIActivity) }
        button8.setOnClickListener { ExpandableListActivity.startExpandablListActivity(this@KotlinUIActivity) }
        button9.setOnClickListener { DataBingListActivity.startDataBingListActivity(this@KotlinUIActivity) }

        /**
         * button10 协程
         */
        button10.setOnClickListener{
            CoroutinesActivity.startCoroutinesActivityActivity(this@KotlinUIActivity)
        }

    }
}
